﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EyFramework.Common;
using EyFramework.Sys.Core;
using ShuJuGj.Core.Dao;
using ShuJuGj.Entity;
using SqlSugar;

namespace ShuJuGj.Core.Service
{
    /// <summary>
    ///  GY_TUPIANXX表的服务实现类 
    /// </summary>
    public class GyTupianxxService : BaseHisService, IGyTupianxxService
    {
		protected readonly IGyTupianxxDao _GyTupianxxDao;

		public GyTupianxxService(IGyTupianxxDao gyTupianxxDao)
		{
			_GyTupianxxDao = gyTupianxxDao;
		}

        public bool checkTuPianxx(string name)
        {
            if (_GyTupianxxDao.GetTuPianxx(name) != null)
            {
                return _GyTupianxxDao.DeleteTuPianxx(name);
            }
            return true;
        }

        public bool Import(List<GyTupianxx> gyTupianxxes)
        {
            _GyTupianxxDao.BeginTrans();
            try
            {
                gyTupianxxes.ForEach(p =>
                {
                    _GyTupianxxDao.Insert(p);
                });
                _GyTupianxxDao.CommitTrans();
            }
            catch (Exception ex)
            {
                _GyTupianxxDao.RollBackTrans();
                throw new BizException(ex.ToString());
            }
            return true;
        }
    }
}
